﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EarringsRecommendationWeb
{
    public class FaceShapeFinder
    {
        public FaceShapeFinder()
        {

        }
        public static string FindShape(double forhead, double cheekBone, double jaw, string checkType)
        {
            if (string.IsNullOrEmpty(checkType))
            {
                checkType = "BigFace";
            }

            string rtn = "";
            double sum = forhead + cheekBone + jaw;
            double forheadRatio = (forhead / sum) * 100;
            double cheekBoneRatio = (cheekBone / sum) * 100;
            double jawRatio = (jaw / sum) * 100;

            getFromDb d = new getFromDb(checkType);

            bool checkForhead = false, checkCheekBone = false, checkJaw = false;

            if (Math.Abs(d.forhead - forheadRatio) <= 5)
            {
                checkForhead = true;
            }
            if ((Math.Abs(d.cheekBone) - cheekBoneRatio) <= 5)
            {
                checkCheekBone = true;
            }
            if ((Math.Abs(d.jaw - jawRatio) <= 5))
            {
                checkJaw = true;
            }

            if (checkForhead && checkCheekBone && checkJaw)
            {
                rtn = checkType;
            }

            return rtn;
        }
    }
    
    public class getFromDb
    {
        public double forhead;
        public double cheekBone;
        public double jaw;
        public getFromDb(string faceshp)
        {
            //get ratio from database            
            this.forhead = 46;
            this.cheekBone = 31;
            this.jaw = 23;
        }
    }

    public  class RoundFace
    {
        private static double _forheadRatio = 33.33;
        private static double _cheekBoneRatio = 33.33;
        private static double _jawlineRatio = 33.33;

        private static double _widthRatio = 50;
        private static double _lengtgRatio = 50;

        private static double _diffPercent = GlobalValue.DIFFRATIO ;

        public  static bool CheckFaceShape(double width, double length, double forhead, double cheekBone, double jaw,string hairline)
        {
            bool _return = false;                   

            //Width and Height
            bool chkWidth = false, chkLength = false; 
            double lengthRatio = Math.Round((length / width), 1);

            if (0 < lengthRatio && lengthRatio < 1.5)
            {
                chkWidth = true;
                chkLength = true;
            }

            //double sumLenght = width + height;
            //double widthPercent = (width / sumLenght) * 100;
            //double lengthPercent = (height / sumLenght) * 100;                      

            //if ((Math.Abs(_widthRatio - widthPercent) <= _diffPercent))
            //{
            //    chkWidth = true;
            //}
            //if ((Math.Abs(_lengtgRatio - lengthPercent) <= _diffPercent))
            //{
            //    chkLength = true;
            //}

            // Forhead:Cheekbone:Jaw
            bool checkForhead = false, checkCheekBone = false, checkJaw = false;

            double[] ratio = new double[] {width, forhead,jaw };
            Array.Sort(ratio);

            double fh = Math.Round((forhead / ratio[0]),0);
            double wd = Math.Round((width / ratio[0]), 0);
            double jw = Math.Round((jaw / ratio[0]), 0);

            if(fh == wd && wd == jw)
            {
                checkForhead = true;
                checkCheekBone = true;
                checkJaw = true;
            }


            //double sum = forhead + cheekBone + jaw;
            //double forheadPercent = (forhead / sum) * 100;
            //double cheekBonePercent = (cheekBone / sum) * 100;
            //double jawPercent = (jaw / sum) * 100;            

            //if ((Math.Abs(_forheadRatio - forheadPercent) <= _diffPercent))
            //{
            //    checkForhead = true;
            //}
            //if ((Math.Abs(_cheekBoneRatio - cheekBonePercent) <= _diffPercent))
            //{
            //    checkCheekBone = true;
            //}
            //if ((Math.Abs(_jawlineRatio - jawPercent) <= _diffPercent))
            //{
            //    checkJaw = true;
            //}
                       
            //Check Hair Line
            bool chkHairLine = false;

            if (hairline == HairLine.Wide.ToString() || hairline == HairLine.Narrow.ToString())
            {
                chkHairLine = true;
            }

            if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            {
                _return = true;
            }

            return _return;
        }
    }

    public class OvalFace
    {
        private static double _forheadRatio = 33.33;
        private static double _cheekBoneRatio = 33.33;
        private static double _jawlineRatio = 33.33;

        private static double _widthRatio = 40;
        private static double _lengthRatio = 60;

        private static double _diffPercent = GlobalValue.DIFFRATIO;


        public static bool CheckFaceShape(double width, double length, double forhead, double cheekBone, double jaw, string hairLine)
        {
            bool _return = false;            

            //Width and Heigth
            double sumLenght = width + length;
            double widthPercent = (width / sumLenght) * 100;
            double lengthPercent = (length / sumLenght) * 100;

            bool chkWidth = false, chkLength = false;

            double lengthRatio = Math.Round((length / width), 1);

            if (1 < lengthRatio && lengthRatio <= 1.5)
            {
                chkWidth = true;
                chkLength = true;
            }
            
            //if ((Math.Abs(_widthRatio - widthPercent) <= _diffPercent))
            //{
            //    chkWidth = true;
            //}
            //if ((Math.Abs(_lengthRatio - lengthPercent) <= _diffPercent))
            //{
            //    chkHeight = true;
            //}

            // Forhead:Cheekbone:Jaw         
            bool checkForhead = false, checkCheekBone = false, checkJaw = false;

            double[] ratio = new double[] { forhead, cheekBone, jaw };
            Array.Sort(ratio);

            double fh = Math.Round((forhead / ratio[0]), 0);
            double cb = Math.Round((cheekBone / ratio[0]), 0);
            double jw = Math.Round((jaw / ratio[0]), 0);

            if (fh ==  jw)
            {
                checkForhead = true;
                checkCheekBone = true;
                checkJaw = true;

            }

            //double sum = forhead + cheekBone + jaw;
            //double forheadPercent = (forhead / sum) * 100;
            //double cheekBonePercent = (cheekBone / sum) * 100;
            //double jawPercent = (jaw / sum) * 100;

            //if ((Math.Abs(_forheadRatio - forheadPercent) <= _diffPercent))
            //{
            //    checkForhead = true;
            //}
            //if ((Math.Abs(_cheekBoneRatio - cheekBonePercent) <= _diffPercent))
            //{
            //    checkCheekBone = true;
            //}
            //if ((Math.Abs(_jawlineRatio - jawPercent) <= _diffPercent))
            //{
            //    checkJaw = true;
            //}                      
                        
            //Check Hair Line
            bool chkHairLine = false;
            if (hairLine == HairLine.Wide.ToString() || hairLine == HairLine.Narrow.ToString())
            {
                chkHairLine = true;
            }

            if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            {
                _return = true;
            }
            return _return;
        }
    }

    public class HeartFace
    {
        private static double _forheadRatio_1 = 50;
        private static double _cheekBoneRatio_1 = 33;
        private static double _jawlineRatio_1 = 17;

        private static double _forheadRatio_2 = 46;        
        private static double _cheekBoneRatio_2 = 31;        
        private static double _jawlineRatio_2 = 23;

        private static double _widthRatio_1 = 50;
        private static double _lengthRatio_1 = 50;

        private static double _widthRatio_2 = 40;
        private static double _lengthRatio_2 = 60;

        private static double _diffPercent = GlobalValue.DIFFRATIO;

        public static bool CheckFaceShape(double width, double length, double forhead, double cheekBone, double jaw, string hairLine)
        {
            bool _return = false;

            //Check Hair Line
            bool chkHairLine = false;
            if (hairLine == HairLine.Wide.ToString())
            {
                chkHairLine = true;
            }
            else
            {
                return false;
            }

            //Width and Height
            bool chkWidth = false, chkLength = false;

            double lengthRatio = Math.Round((length / width), 0);

            if (1 <= lengthRatio && lengthRatio <= 1.5)
            {
                chkWidth = true;
                chkLength = true;
            }

            //double sumLenght = width + length;
            //double widthPercent = (width / sumLenght) * 100;
            //double heightPercent = (length / sumLenght) * 100;

            //if ((Math.Abs(_widthRatio_1 - widthPercent) <= _diffPercent))
            //{
            //    chkWidth = true;
            //}
            //if ((Math.Abs(_lengthRatio_1 - heightPercent) <= _diffPercent))
            //{
            //    chkLength = true;
            //}

            // Forhead:Cheekbone:Jaw
            bool checkForhead = false, checkCheekBone = false, checkJaw = false;

            double[] ratio = new double[] {width, forhead, cheekBone, jaw };
            Array.Sort(ratio);

            double fh = Math.Round((forhead / ratio[0]), 0);
            double wd = Math.Round((width / ratio[0]), 0);
            double jw = Math.Round((jaw / ratio[0]), 0);

            if (fh == wd && wd == jw)
            {
                checkForhead = true;
                checkCheekBone = true;
                checkJaw = true;

            }

            #region Comment
            //double sum = forhead + cheekBone + jaw;
            //double forheadPercent = (forhead / sum) * 100;
            //double cheekBonePercent = (cheekBone / sum) * 100;
            //double jawPercent = (jaw / sum) * 100;           

            //if ((Math.Abs(_forheadRatio_1 - forheadPercent) <= _diffPercent))
            //{
            //    checkForhead = true;
            //}
            //if ((Math.Abs(_cheekBoneRatio_1 - cheekBonePercent) <= _diffPercent))
            //{
            //    checkCheekBone = true;
            //}
            //if ((Math.Abs(_jawlineRatio_1 - jawPercent) <= _diffPercent))
            //{
            //    checkJaw = true;
            //}                 

            //if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkHeight && chkHairLine)
            //{
            //    _return = true;
            //}
            //else if (checkForhead && checkCheekBone && checkJaw && chkHairLine)
            //{
            //    //Width and Height
            //    if ((Math.Abs(_widthRatio_2 - widthPercent) <= _diffPercent))
            //    {
            //        chkWidth = true;
            //    }
            //    if ((Math.Abs(_lengthRatio_2 - heightPercent) <= _diffPercent))
            //    {
            //        chkHeight = true;
            //    }
            //    if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkHeight && chkHairLine)
            //    {
            //        _return = true;
            //    }
            //}
            //else
            //{
            //    checkForhead = false; checkCheekBone = false; checkJaw = false;
            //    chkWidth = false; chkHeight = false;

            //    if ((Math.Abs(_forheadRatio_2 - forheadPercent) <= _diffPercent))
            //    {
            //        checkForhead = true;
            //    }
            //    if ((Math.Abs(_cheekBoneRatio_2 - cheekBonePercent) <= _diffPercent))
            //    {
            //        checkCheekBone = true;
            //    }
            //    if ((Math.Abs(_jawlineRatio_2 - jawPercent) <= _diffPercent))
            //    {
            //        checkJaw = true;
            //    }

            //    if ((Math.Abs(_widthRatio_2 - widthPercent) <= _diffPercent))
            //    {
            //        chkWidth = true;
            //    }
            //    if ((Math.Abs(_lengthRatio_2 - heightPercent) <= _diffPercent))
            //    {
            //        chkHeight = true;
            //    }

            //    if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkHeight && chkHairLine)
            //    {
            //        _return = true;
            //    }
            //    else if (checkForhead && checkCheekBone && checkJaw && chkHairLine)
            //    {
            //        //Width and Height
            //        if ((Math.Abs(_widthRatio_1 - widthPercent) <= _diffPercent))
            //        {
            //            chkWidth = true;
            //        }
            //        if ((Math.Abs(_lengthRatio_1 - heightPercent) <= _diffPercent))
            //        {
            //            chkHeight = true;
            //        }
            //        if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkHeight && chkHairLine)
            //        {
            //            _return = true;
            //        }
            //    }
            //}
            #endregion

            if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            {
                _return = true;
            }

            return _return;
        }
    }

    public class SquareFace
    {
        private static double _forheadRatio_1 = 33.33;
        private static double _cheekBoneRatio_1 = 33.33;
        private static double _jawlineRatio_1 = 33.33;

        private static double _forheadRatio_2 = 28.5;        
        private static double _cheekBoneRatio_2 = 28.5;        
        private static double _jawlineRatio_2 = 43;

        private static double _widthRatio_1 = 50;
        private static double _lengthRatio_1 = 50;

        private static double _widthRatio_2 = 40;
        private static double _lengthRatio_2 = 60;

        private static double _diffPercent = GlobalValue.DIFFRATIO;

        public static bool CheckFaceShape(double width, double length, double forhead, double cheekBone, double jaw, string hairLine)
        {
            bool _return = false;

            //Check Hair Line
            bool chkHairLine = false;
            if (hairLine == HairLine.Wide.ToString())
            {
                chkHairLine = true;
            }
            else
            {
                return false;
            }           

            //Width and Height
            bool chkWidth = false, chkLength = false;

            double lengthRatio = Math.Round((length / width), 1);

            if (1 <= lengthRatio && lengthRatio <= 1.5)
            {
                chkWidth = true;
                chkLength = true;
            }
           
            //double sumLenght = width + length;
            //double widthPercent = (width / sumLenght) * 100;
            //double lengthPercent = (length / sumLenght) * 100;

            //if ((Math.Abs(_widthRatio_1 - widthPercent) <= _diffPercent))
            //{
            //    chkWidth = true;
            //}
            //if ((Math.Abs(_lengthRatio_1 - lengthPercent) <= _diffPercent))
            //{
            //    chkLength = true;
            //}

            // Forhead:Cheekbone:Jaw
            bool checkForhead = false, checkCheekBone = false, checkJaw = false;
            double[] ratio = new double[] { width, forhead, jaw };
            Array.Sort(ratio);

            double fh = Math.Round((forhead / ratio[0]), 0);
            double wd = Math.Round((width / ratio[0]),0);
            double jw = Math.Round((jaw / ratio[0]), 0);

            if (fh == wd && wd == jw)
            {
                checkForhead = true;
                checkCheekBone = true;
                checkJaw = true;

            }

            #region Comment

            //double sum = forhead + cheekBone + jaw;
            //double forheadPercent = (forhead / sum) * 100;
            //double cheekBonePercent = (cheekBone / sum) * 100;
            //double jawPercent = (jaw / sum) * 100;

            //if ((Math.Abs(_forheadRatio_1 - forheadPercent) <= _diffPercent))
            //{
            //    checkForhead = true;
            //}
            //if ((Math.Abs(_cheekBoneRatio_1 - cheekBonePercent) <= _diffPercent))
            //{
            //    checkCheekBone = true;
            //}
            //if ((Math.Abs(_jawlineRatio_1 - jawPercent) <= _diffPercent))
            //{
            //    checkJaw = true;
            //}           

            //if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkHeight && chkHairLine)
            //{
            //    _return = true;
            //}
            //else if (checkForhead && checkCheekBone && checkJaw && chkHairLine)
            //{
            //    //Width and Height
            //    if ((Math.Abs(_widthRatio_2 - widthPercent) <= _diffPercent))
            //    {
            //        chkWidth = true;
            //    }
            //    if ((Math.Abs(_lengthRatio_2 - lengthPercent) <= _diffPercent))
            //    {
            //        chkLength = true;
            //    }
            //    if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            //    {
            //        _return = true;
            //    }
            //}
            //else
            //{
            //    checkForhead = false; checkCheekBone = false; checkJaw = false;
            //    chkWidth = false; chkLength = false;

            //    if ((Math.Abs(_forheadRatio_2 - forheadPercent) <= _diffPercent))
            //    {
            //        checkForhead = true;
            //    }
            //    if ((Math.Abs(_cheekBoneRatio_2 - cheekBonePercent) <= _diffPercent))
            //    {
            //        checkCheekBone = true;
            //    }
            //    if ((Math.Abs(_jawlineRatio_2 - jawPercent) <= _diffPercent))
            //    {
            //        checkJaw = true;
            //    }

            //    //Width and Height
            //    if ((Math.Abs(_widthRatio_2 - widthPercent) <= _diffPercent))
            //    {
            //        chkWidth = true;
            //    }
            //    if ((Math.Abs(_lengthRatio_2 - lengthPercent) <= _diffPercent))
            //    {
            //        chkLength = true;
            //    }

            //    if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            //    {
            //        _return = true;
            //    }
            //    else if (checkForhead && checkCheekBone && checkJaw && chkHairLine)
            //    {
            //        //Width and Height
            //        if ((Math.Abs(_widthRatio_1 - widthPercent) <= _diffPercent))
            //        {
            //            chkWidth = true;
            //        }
            //        if ((Math.Abs(_lengthRatio_1 - lengthPercent) <= _diffPercent))
            //        {
            //            chkLength = true;
            //        }
            //        if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            //        {
            //            _return = true;
            //        }
            //    }
            //}
            #endregion

            if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            {
                _return = true;
            }

            return _return;
        }
    }

    public class InvertedTriangleFace
    {
        private static double _forheadRatio = 45;
        private static double _cheekBoneRatio = 33;
        private static double _jawlineRatio = 22;

        private static double _widthRatio = 40;
        private static double _lengthRatio = 60;

        private static double _diffPercent = GlobalValue.DIFFRATIO;

        public static bool CheckFaceShape(double width, double length, double forhead, double cheekBone, double jaw, string hairLine)
        {
            bool _return = false;

            //Check Hair Line
            bool chkHairLine = false;
            if (hairLine == HairLine.Wide.ToString())
            {
                chkHairLine = true;
            }
            else
            {
                return false;
            }

            //Width and Height
            bool chkWidth = false, chkLength = false;
            double lengthRatio = Math.Round((length / width), 1);

            if (1 < lengthRatio && lengthRatio <= 1.5)
            {
                chkWidth = true;
                chkLength = true;
            }

            //double sumLenght = width + length;
            //double widthPercent = (width / sumLenght) * 100;
            //double lengthPercent = (length / sumLenght) * 100;

            //if ((Math.Abs(_widthRatio - widthPercent) <= _diffPercent))
            //{
            //    chkWidth = true;
            //}
            //if ((Math.Abs(_lengthRatio - lengthPercent) <= _diffPercent))
            //{
            //    chkHeight = true;
            //}

            // Forhead:Cheekbone:Jaw
            bool checkForhead = false, checkCheekBone = false, checkJaw = false;
            //double[] ratio = new double[] { forhead, cheekBone, jaw };
            //Array.Sort(ratio);

            //double fh = Math.Round((forhead / ratio[0]), 0);
            //double jw = Math.Round((jaw / ratio[0]), 0);

            if (forhead > jaw)
            {
                checkForhead = true;
                checkCheekBone = true;
                checkJaw = true;

            }        

            //double sum = forhead + cheekBone + jaw;
            //double forheadPercent = (forhead / sum) * 100;
            //double cheekBonePercent = (cheekBone / sum) * 100;
            //double jawPercent = (jaw / sum) * 100;

            //if ((Math.Abs(_forheadRatio - forheadPercent) <= _diffPercent))
            //{
            //    checkForhead = true;
            //}
            //if ((Math.Abs(_cheekBoneRatio - cheekBonePercent) <= _diffPercent))
            //{
            //    checkCheekBone = true;
            //}
            //if ((Math.Abs(_jawlineRatio - jawPercent) <= _diffPercent))
            //{
            //    checkJaw = true;
            //}

            if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            {
                _return = true;
            }

            return _return;
        }
    }

    public class OblongFace
    {
        private static double _forheadRatio = 33.33;
        private static double _cheekBoneRatio = 33.33;
        private static double _jawlineRatio = 33.33;

        private static double _widthRatio = 1;
        private static double _lengthRatio = 1.5;

        private static double _diffPercent = GlobalValue.DIFFRATIO;

        public static bool CheckFaceShape(double width, double length, double forhead, double cheekBone, double jaw, string hairLine)
        {
            bool _return = false;            

            //Width and Height
            //double sumLenght = width + height;
            //double widthPercent = (width / sumLenght) * 100;
            //double heightPercent = (height / sumLenght) * 100;

            double heightCal = length / width;

            bool checkForhead = false, checkCheekBone = false, checkJaw = false;
            double[] ratio = new double[] { forhead, cheekBone, jaw };
            Array.Sort(ratio);

            double fh = Math.Round((forhead / ratio[0]), 0);
            double jw = Math.Round((jaw / ratio[0]), 0);

            if (fh == jw)
            {
                checkForhead = true;
                checkCheekBone = true;
                checkJaw = true;
            }   

            //double sum = forhead + cheekBone + jaw;
            //double forheadPercent = (forhead / sum) * 100;
            //double cheekBonePercent = (cheekBone / sum) * 100;
            //double jawPercent = (jaw / sum) * 100;
            //if ((Math.Abs(_forheadRatio - forheadPercent) <= _diffPercent))
            //{
            //    checkForhead = true;
            //}
            //if ((Math.Abs(_cheekBoneRatio - cheekBonePercent) <= _diffPercent))
            //{
            //    checkCheekBone = true;
            //}
            //if ((Math.Abs(_jawlineRatio - jawPercent) <= _diffPercent))
            //{
            //    checkJaw = true;
            //}

            //Width and Height
            bool chkWidth = false, chkLength = false;
            bool chkHairLine = false;
            if (heightCal > _lengthRatio)
            {
                chkWidth = true;
                chkLength = true;
                
                //Check Hair Line
                if (hairLine == HairLine.Wide.ToString() || hairLine == HairLine.Narrow.ToString())
                {
                    chkHairLine = true;
                }

                if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
                {
                    _return = true;
                }
            }
            
            return _return;
        }
    }

    public class DiamondFace
    {
        private static double _forheadRatio = 28.5;
        private static double _cheekBoneRatio = 43;
        private static double _jawlineRatio = 28.5;

        private static double _widthRatio = 40;
        private static double _lengthRatio = 60;

        private static double _diffPercent = GlobalValue.DIFFRATIO;

        public static bool CheckFaceShape(double width, double length, double forhead, double cheekBone, double jaw, string hairLine)
        {
            bool _return = false;

            //Check Hair Line
            bool chkHairLine = false;
            if (hairLine == HairLine.Narrow.ToString())
            {
                chkHairLine = true;
            }
            else
            {
                return false;
            }                   

            //Width and Height
            bool chkWidth = false, chkLength = false;
            double lengthRatio = Math.Round((length / width), 1);

            if (1 < lengthRatio && lengthRatio <= 1.5)
            {
                chkWidth = true;
                chkLength = true;
            }

            //double sumLenght = width + length;
            //double widthPercent = (width / sumLenght) * 100;
            //double lengthPercent = (length / sumLenght) * 100;
            
            //if ((Math.Abs(_widthRatio - widthPercent) <= _diffPercent))
            //{
            //    chkWidth = true;
            //}
            //if ((Math.Abs(_lengthRatio - lengthPercent) <= _diffPercent))
            //{
            //    chkLength = true;
            //}

            // Forhead:Cheekbone:Jaw
            bool checkForhead = false, checkCheekBone = false, checkJaw = false;
            double[] ratio = new double[] {width, forhead, cheekBone, jaw };
            Array.Sort(ratio);

            double fh = Math.Round((forhead / ratio[0]), 0);
            double wd = Math.Round((width / ratio[0]), 0);
            double jw = Math.Round((jaw / ratio[0]), 0);

            if (fh == jw && wd > fh)
            {
                checkForhead = true;
                checkCheekBone = true;
                checkJaw = true;
            }   

            //double sum = forhead + cheekBone + jaw;
            //double forheadPercent = (forhead / sum) * 100;
            //double cheekBonePercent = (cheekBone / sum) * 100;
            //double jawPercent = (jaw / sum) * 100;

            //if ((Math.Abs(_forheadRatio - forheadPercent) <= _diffPercent))
            //{
            //    checkForhead = true;
            //}
            //if ((Math.Abs(_cheekBoneRatio - cheekBonePercent) <= _diffPercent))
            //{
            //    checkCheekBone = true;
            //}
            //if ((Math.Abs(_jawlineRatio - jawPercent) <= _diffPercent))
            //{
            //    checkJaw = true;
            //}


            if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            {
                _return = true;
            }
           

            return _return;
        }
    }

    public class PearFace
    {
        private static double _widthRatio = 40;
        private static double _lengthRatio = 60;

        private static double _diffPercent = GlobalValue.DIFFRATIO;

        public static bool CheckFaceShape(double width, double length, double forhead, double cheekBone, double jaw, string hairLine)
        {
            bool _return = false;

            //Check Hair Line
            bool chkHairLine = false;
            if (hairLine == HairLine.Narrow.ToString())
            {
                chkHairLine = true;
            }
            else
            {
                return false;
            }

            //Width and Height
            bool chkWidth = false, chkLength = false;
            double lengthRatio = Math.Round((length / width), 1);

            if (1 < lengthRatio && lengthRatio <= 1.5)
            {
                chkWidth = true;
                chkLength = true;
            }

            // Forhead:Cheekbone:Jaw
            bool checkForhead = false, checkCheekBone = false, checkJaw = false;
            double[] ratio = new double[] { width, forhead, cheekBone, jaw };
            Array.Sort(ratio);

            double fh = Math.Round((forhead / ratio[0]), 0);
            double wd = Math.Round((width / ratio[0]), 0);
            double jw = Math.Round((jaw / ratio[0]), 0);

            if (fh < wd && wd < jw)
            {
                checkForhead = true;
                checkCheekBone = true;
                checkJaw = true;

            } 
  
            //bool chkFHJW = false;
            //if(jaw > width && width > forhead)
            //{
            //    chkFHJW = true;
            //}

            #region Comment

            ////Width and Height
            //bool chkWidth = false, chkHeight = false;
            //double sumLenght = width + height;
            //double widthPercent = (width / sumLenght) * 100;
            //double heightPercent = (height / sumLenght) * 100;

            //if ((Math.Abs(_widthRatio - widthPercent) <= _diffPercent))
            //{
            //    chkWidth = true;
            //}
            //if ((Math.Abs(_heightRatio - heightPercent) <= _diffPercent))
            //{
            //    chkHeight = true;
            //}

            //// Forhead:Cheekbone:Jaw
            //bool checkForhead = false, checkCheekBone = false, checkJaw = false;
            //double sum = forhead + cheekBone + jaw;
            //double forheadPercent = (forhead / sum) * 100;
            //double cheekBonePercent = (cheekBone / sum) * 100;
            //double jawPercent = (jaw / sum) * 100;

            //if ((Math.Abs(_forheadRatio - forheadPercent) <= _diffPercent))
            //{
            //    checkForhead = true;
            //}
            //if ((Math.Abs(_cheekBoneRatio - cheekBonePercent) <= _diffPercent))
            //{
            //    checkCheekBone = true;
            //}
            //if ((Math.Abs(_jawlineRatio - jawPercent) <= _diffPercent))
            //{
            //    checkJaw = true;
            //}

            //if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkHeight && chkHairLine)
            //{
            //    _return = true;
            //}

            #endregion

            if (checkForhead && checkCheekBone && checkJaw && chkWidth && chkLength && chkHairLine)
            {
                _return = true;
            }

            return _return;
        }
    }
}